/*
 * @lc app=leetcode.cn id=179 lang=cpp
 *
 * [179] 最大数
 */

// @lc code=start
class Solution {
public:
    static bool greater(const string& a, const string & b)
    {
        return a + b > b + a;
    }
    string largestNumber(vector<int>& nums) {
        vector<string> strs;
        for(auto i:nums)
        {
            strs.push_back(to_string(i));
        }
        sort(strs.begin(), strs.end(), greater);
        string res;
        for(auto i:strs)
        {
            res += i;
        }
        if(res[0] == '0')
        {
            return "0";
        }
        return res;
    }
};
// @lc code=end

